var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, i) {
    var o, a = arguments.length, r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, n) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, n, i); else for (var s = t.length - 1; 0 <= s; s--) (o = t[s]) && (r = (a < 3 ? o(r) : 3 < a ? o(e, n, r) : o(e, n)) || r);
    return 3 < a && r && Object.defineProperty(e, n, r), r;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("AudioManager"), s = e("Global"), c = e("EggsPetItemView"), l = e("PersonView"), d = e("PetManager"), u = e("MyProfitView"), p = e("GameConfig"), h = e("GameData"), f = e("EggsManager"), g = e("DataManager"), m = e("LoadManager"), y = e("UIManager"), v = cc._decorator, w = v.ccclass, b = v.property, P = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.petView = null, t.titleSprite = null, t.freeLabel = null, t.useBtn = null, 
        t.lockBtn = null, t.toggleContainer = null, t.item = null, t.items = [], t.idx = null, 
        t.isInit = !1, t;
    }
    return i(t, e), t.prototype.onEnable = function() {
        e.prototype.onEnable.call(this), this.isInit || (this.isInit = !0, this.init());
    }, t.prototype.onClickUseBtn = function(t) {
        r.default.getInstance().playAudio("按钮2"), this.pushEvent("免费使用" + s.G.eggGunModelList[this.idx].m), 
        this.callback(t);
    }, t.prototype.init = function() {
        var i = this;
        GA.Info.underCheck ? (this.items.push(this.item), this.idx = 0, p.GC.petModelList.forEach(function(t, e) {
            var n;
            0 < e && 0 < t.form && ((t = (n = cc.instantiate(i.item.node)).getComponent(c.default)) && (t.init(e), 
            n.parent = i.toggleContainer.node, i.items.push(t)));
        }), this.item.init(0), this.items.forEach(function(t) {
            var e = new cc.Component.EventHandler();
            e.target = i.node, e.component = "EggsPetView", e.handler = "change", t.toggle.checkEvents.push(e);
        })) : (this.items.push(this.item), this.idx = 0, p.GC.petModelList.forEach(function(t, e) {
            var n;
            0 < e && 0 < t.form && -2 != f.default.getInstance().checkEggPet(e) && ((t = (n = cc.instantiate(i.item.node)).getComponent(c.default)) && (t.init(e), 
            n.parent = i.toggleContainer.node, i.items.push(t)));
        }), this.item.init(0), this.items.forEach(function(t) {
            var e = new cc.Component.EventHandler();
            e.target = i.node, e.component = "EggsPetView", e.handler = "change", t.toggle.checkEvents.push(e);
        })), this.refresh(0);
    }, t.prototype.callback = function() {
        s.G.tryPetIdx = p.GC.petModelList[this.idx].id + p.GC.petModelList[this.idx].form, 
        this.refresh(), 200 <= s.G.tryPetIdx ? (h.GD.petDataIdx = 2, y.default.getInstance().loadPopPnl("egg_reward", {
            type: s.RewardType.ELF,
            idx: s.G.tryPetIdx
        })) : 100 <= s.G.tryPetIdx ? (h.GD.petDataIdx = 1, y.default.getInstance().loadPopPnl("egg_reward", {
            type: s.RewardType.DRAGON,
            idx: s.G.tryPetIdx
        })) : (h.GD.petDataIdx = 0, y.default.getInstance().loadPopPnl("egg_reward", {
            type: s.RewardType.PET,
            idx: s.G.tryPetIdx
        })), g.default.getInstance().save(), this.delayBtn();
    }, t.prototype.change = function(t) {
        t = t.target;
        t && (t = t.getComponent(c.default), this.idx = t.idx, this.refresh());
    }, t.prototype.refresh = function(t) {
        void 0 === t && (t = this.idx), this.petView.initPet(p.GC.petModelList[t].id + p.GC.petModelList[t].form), 
        m.default.getInstance().loadSpriteFrame({
            url: "image/eggs/超级" + p.GC.petModelList[t].m + "标题@2x",
            sprite: this.titleSprite
        }), GA.Info.underCheck ? (this.freeLabel.node.parent.active = !0, this.lockBtn.active = !1, 
        this.myButton.node.active = !0, this.useBtn.node.active = !1, this.freeLabel.string = "今日免费使用次数：0") : (t = f.default.getInstance().checkEggPet(t)) < 0 || !d.default.getInstance().isHas(this.idx) ? this.showLock() : 0 < t ? (this.freeLabel.node.parent.active = !0, 
        this.petView.skeleton.node.color = cc.Color.WHITE, this.lockBtn.active = !1, this.myButton.node.active = !1, 
        this.useBtn.node.active = !0, this.freeLabel.string = "今日免费使用次数：" + t) : (this.freeLabel.node.parent.active = !0, 
        this.petView.skeleton.node.color = cc.Color.WHITE, this.lockBtn.active = !1, this.myButton.node.active = !0, 
        this.useBtn.node.active = !1, this.freeLabel.string = "今日免费使用次数：0");
    }, t.prototype.showLock = function() {
        this.freeLabel.node.parent.active = !1, this.petView.skeleton.node.color = cc.Color.BLACK, 
        this.lockBtn.active = !0, this.myButton.node.active = !1, this.useBtn.node.active = !1;
    }, a([ b(l.default) ], t.prototype, "petView", void 0), a([ b(cc.Sprite) ], t.prototype, "titleSprite", void 0), 
    a([ b(cc.Label) ], t.prototype, "freeLabel", void 0), a([ b(cc.Button) ], t.prototype, "useBtn", void 0), 
    a([ b(cc.Node) ], t.prototype, "lockBtn", void 0), a([ b(cc.ToggleContainer) ], t.prototype, "toggleContainer", void 0), 
    a([ b(c.default) ], t.prototype, "item", void 0), a([ w ], t);
}(u.default);

n.default = P;